package com.dg.gallery

import java.util.List;

import com.db.gallery.Project
import com.db.gallery.ProjectImage

class GalleryProject {

	List<List<ProjectImage>> imageRows = null
	Project project = null
	
	GalleryProject(Project aProject) {
		imageRows = []
		project = aProject
		
		def images = project.images
		List<ProjectImage> row = []
		int columnCount = 0
		
		for (ProjectImage image in images) {
			++columnCount
			
			if (columnCount > 4) {
				imageRows.add(row)
				row = []
				columnCount = 1
			}
			
			row.add(image)
		}
		
		if (columnCount <= 4) {
			imageRows.add(row)
		}
	}
	
}